package com.yanjin.test.presenter;

import java.lang.ref.WeakReference;

/**
 * Created by Sigthp-P-Department on 2018/6/19.
 */

public class BasePresenter<V> {
    private WeakReference<V> reference;

    public void attachView(V view) {
        reference = new WeakReference<V>(view);
    }

    public V getView() {
        return reference.get();
    }

    public boolean isViewAttached() {
        return reference != null && reference.get() != null;
    }

    public void disAttachView() {
        if (reference != null) {
            reference.clear();
            reference = null;
        }
    }
}
